package com.ts.api.module.match.market.internal.sort.strategy;

import com.gitee.apanlh.util.base.CollUtils;
import com.ts.api.module.channel.entity.po.ChannelMarketPO;
import com.ts.api.module.match.market.internal.sort.model.ChannelMarketSort;
import com.ts.api.module.match.market.internal.sort.model.ChannelMarketSortResult;
import org.springframework.stereotype.Component;

import java.util.Comparator;
import java.util.List;

/**
 *  渠道贷超-价格优先
 *
 *  @author Pan
 */
@Component
public class ChanelMarketPriceSort implements ChannelMarketSortStrategy {

    @Override
    public ChannelMarketSortResult sort(ChannelMarketSort channelMarketSort) {
        List<ChannelMarketPO> listMarket = channelMarketSort.getListMarket();

        //  价格排序优先
        List<ChannelMarketPO> copy = CollUtils.copy(listMarket);
        copy.sort(Comparator.comparing(ChannelMarketPO::getPrice, Comparator.reverseOrder()));
        return ChannelMarketSortResult.of(copy);
    }
}
